import re

# 以Hello开头
beginsRegex = re.compile(r'^Hello')
result = beginsRegex.search('Hello World.')
print(result.group())
result2 = beginsRegex.search('Hey, Hello World.')
print(result2)

# 以数字结尾
endsRegex = re.compile(r'\d$')
mo = endsRegex.search(r'You are 42')
print(mo.group())
mo2 = endsRegex.search(r'You are 42.')
print(mo2)

# 全部数字的字符串
wholeStringIsNum = re.compile(r'^\d+$')
mo3 = wholeStringIsNum.search(r'1234567890')
print(mo3.group())
mo4 = wholeStringIsNum.search(r'123abc4567890')
print(mo4)
mo5 = wholeStringIsNum.search(r'1234 567890')
print(mo5)
